package com.xcity.game.combat.skill.impl;

import com.xcity.game.combat.Action;
import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.CombatUtils;
import com.xcity.game.combat.attr.CombatAttributeType;
import com.xcity.game.combat.skill.CombatSkill;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.skill.Skill;

/**
 * 不寒而栗<br/>
 * 豪门就是任性，随机削减一个敌方目标{0=50#0}%能量值，不足50%按50%计算
 * @author yang.li
 *
 */
public class COMBAT_SKILL_90110 extends CombatSkill {

	public COMBAT_SKILL_90110(Skill skill) {
		super(skill);
	}
	
	@Override
	public void calcDamage(Action action) {
		float rate = skill.getParameter(0) / GameStaticConfig.percentBase;
		CombatUnit source = action.unit;
		CombatUnit target = action.target.getUnitRandomly();
		if (target != null) {
			// 伤害
			ActionEffect effect = action.addTarget(target);
			target = effect.getUnit(); // 修正目标
//			int damage = CombatUtils.calcCommonMagicDamage(action.unit, target);
//			effect.effect(CombatAttributeType.HP, -damage);
			CombatUtils.calcMagicAttack(effect);
			// reduce mp
			int mpDelta = (int) (source.getMaxMp() * rate);
			mpDelta = Math.max(mpDelta, 1);
			effect.effect(CombatAttributeType.MP, -mpDelta);
		}
	}

}
